package com.symaster.common.swing.list;

import com.symaster.common.swing.config.AppConfig;
import com.symaster.common.swing.list.item.SyzdListItem;
import com.symaster.common.swing.style.Style;

import javax.swing.*;
import java.awt.*;

/**
 * @author yinmiao
 * @date 2022-01-26 13:47
 */
public class SyzdListPanel extends JPanel {

    public static final int ITEM_WIDTH_TYPE_FULL = 1;
    public static final int ITEM_WIDTH_TYPE_ASSIGN = 2;

    public final int itemWidth;
    public final int itemHeight;
    public final int itemWidthType;

    public SyzdListPanel(int itemWidth, int itemHeight, int itemWidthType) {
        this.itemWidth = itemWidth;
        this.itemHeight = itemHeight;
        this.itemWidthType = itemWidthType;
        initPage(itemWidth, itemHeight, AppConfig.getColor("main_background_color"), 5, 5);
    }

    public SyzdListPanel(int itemWidth, int itemHeight, int itemWidthType, Color backgroundColor) {
        this.itemWidth = itemWidth;
        this.itemHeight = itemHeight;
        this.itemWidthType = itemWidthType;
        initPage(itemWidth, itemHeight, backgroundColor, 5, 5);
    }

    public SyzdListPanel(int itemWidth, int itemHeight, int itemWidthType, Color backgroundColor, int hGap, int vGap) {
        this.itemWidth = itemWidth;
        this.itemHeight = itemHeight;
        this.itemWidthType = itemWidthType;
        initPage(itemWidth, itemHeight, backgroundColor, hGap, vGap);
    }

    public void put(SyzdListItem item) {

    }

    private void initPage(int itemWidth, int itemHeight, Color backgroundColor, int hGap, int vGap) {
        this.setLayout(new FlowLayout(FlowLayout.CENTER, hGap, vGap));
        this.setBackground(backgroundColor);
        Style.setBorder(Style.BORDER_EMPTY, this);
    }
}
